package yns.springcloud.oakwood.guide.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.serviceregistry.Registration;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import yns.springcloud.oakwood.guide.configure.Configure;

@RestController
public class ConfigServerController {

	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private Configure configure;

	@Autowired
	private Registration registration;

	
	@GetMapping("/")
	public String configure() {
		String serverInfo = "ServiceId : " + registration.getServiceId() + " Host : " + registration.getHost()
				+ " Port : " + registration.getPort();
		
		logger.info(configure.getSpringCloudConfigServerGitUri());
		logger.info(configure.getSpringCloudConfigServerGitSearchPaths());
		logger.info(configure.getSpringCloudConfigServerGitBasedir());
		logger.info(configure.getSpringCloudConfigServerGitDefaultLabel());
//		logger.info(configure.getSpringCloudConfigLabel());
		logger.info(serverInfo);

		return serverInfo;
	}
}
